home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacHack 1997
/
MacHack 1997.toast
/
Hacks
/
Hacks ’95
/
Search Example
/
Search.c
< prev
next >
Wrap
Text File
|
1994-04-03
|
740b
|
39 lines
/*Search.c*/
#include <stdio.h>
#include <string.h>
#include "Search.h"
short SearchDocument (char *path, char *args, char *data)
{
FILE *f;
char line [256];
int i;
if (f=fopen (path, "r")) {
data [0]='\0';
for (i=0;i<strlen(args);i++)
args[i] = toupper(args[i]);
fgets (line, sizeof (line), f);
while (!feof(f)) {
line[strlen(line)-1] = '\0';
if (line[0]=='@') {
if (!strcmp (&line[1], args)) {
fgets (line, sizeof (line), f);
while (!feof(f) && line[0]!='@') {
strcat (data, line);
fgets (line, sizeof (line), f);
}
}
else {
fgets (line, sizeof (line), f);
}
}
else {
fgets (line, sizeof (line), f);
}
}
return (0);
}
else return (-1);
}